package main

import (
	"fmt"
	"time"
)

type ActivityInfo struct {
	ActivityCode string
	ActivityName string
	ActivityType int
	StartTime    time.Time
	EndTime      time.Time
	Status       int
	YunXiaoNode  int
}

type AfterJoinEvent interface {
	Handle(info ActivityInfo) error
}

type NoticeJoinEvent struct {
	ActivityInfo
}

func (e *NoticeJoinEvent) Handle(info ActivityInfo) error {
	fmt.Println(info.ActivityCode, "NoticeJoinEvent done")
	return nil
}

type AddHelpNumEvent struct {
	ActivityInfo
}

func (e *AddHelpNumEvent) Handle(info ActivityInfo) error {
	fmt.Println(info.ActivityCode, "AddHelpNumEvent done")
	return nil
}

type EventGroup struct {
	Events []AfterJoinEvent
}

func (EVE *EventGroup) Add(e AfterJoinEvent) {
	EVE.Events = append(EVE.Events, e)
}

func main() {
	info := ActivityInfo{ActivityCode: "abc"}
	noticeE := &NoticeJoinEvent{}
	AddHelpNumE := &AddHelpNumEvent{}
	eventGroup := new(EventGroup)
	eventGroup.Add(noticeE)
	eventGroup.Add(AddHelpNumE)
	fmt.Println(eventGroup.Events)
	for _, eve := range eventGroup.Events {
		go func(e AfterJoinEvent, a ActivityInfo) {
			e.Handle(a)
		}(eve, info)
	}

	time.Sleep(time.Second)

}
